<style type="text/css" title="text/css">
.div_stl001 label.cabinet
{
    width: 100px;
    height: 28px;
    background: url(<?php echo base_url()?>image/select_ads.jpg) 0 0 no-repeat;
    display: block;
    overflow: hidden;
    cursor: pointer;
	margin-bottom:5px;
    padding:0;    
}

.div_stl001 label.cabinet input.file
{
    position: relative;
    height: 100%;
    width: auto;
    opacity: 0;
    -moz-opacity: 0;
    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
}
</style>

<?php
$CI =& get_instance();
$CI->load->database();
$CI->load->library("front/header_lib");

    $title = 'Request a Banner';
	$metakey_page = 'banner';
    $metadesc_page = ' request a advertiser  company banner in kypris guide';
$CI->header_lib->display_header_element(array("script"=>array("jquery-1.4.2"),"page_title"=>$title,"metakey_page"=>$metakey_page,"metadesc_page"=>$metadesc_page));
$datas[''] = '' ;
$CI->header_lib->display_header($datas);

?>

<script src="<?php  echo base_url(); ?>js/jquery-1.4.2.js"></script>
<script src="<?php  echo base_url(); ?>js/jquery.validate.js"></script>

<script type="text/javascript" src="<?php echo base_url()?>js/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="<?php echo base_url();?>style/jquery-ui.css" />

<script src="<?php echo base_url(); ?>js/jquery.NobleCount.min.js"></script>
<script src="<?php echo base_url(); ?>js/ajaxfileupload.js"></script>
<script src="<?php echo base_url(); ?>js/si.files.js"></script>

  
<script type="text/javascript">// function upload jquery
function load_image()
{
var imgpath = document.getElementById('fileToUpload').value;

if(imgpath != "")
{
// code to get File Extension..

var arr1 = new Array;

arr1 = imgpath.split("\\");

var len = arr1.length;

var img1 = arr1[len-1];

var filext = img1.substring(img1.lastIndexOf(".")+1);

// Checking Extension

if(filext == "jpg" || filext == "jpeg" || filext == "gif" )

document.getElementById('fileToUpload').src = imgpath;

else

{
alert("Invalid Image Format Selected");
//document.getElementById('fileToUpload').value = "";

return false;

}

}

}
function ajaxFileUpload(){
 
 
    $("#loading")
    .ajaxStart(function(){
        $(this).show();
    })
    .ajaxComplete(function(){
        $(this).hide();
    });
    var check_img=load_image();
    if(check_img == false)
    {
        return false;
    }
    
    $.ajaxFileUpload({
        url:'<?php echo site_url('ajax_upload/upload_directory_image/upload/banners')?>',
        secureuri:false,
        fileElementId:'fileToUpload',
        dataType: 'json',
        success: function (data, status){
            if(typeof(data.error) != 'undefined')
            {
                if(data.error != ''){
                    $("#info").html('<span >'+data.error+"</span>");
                }else{ 
                    $("#info").html('<img width="120px" height="60px" src="<?php echo base_url();?>uploads/banners/'+data.msg
                    +'"  />'
                    +'<input type="hidden" name="upload" id="upload" value="'+data.msg +'">');
                   
                }
            }
        },
        error: function (data, status, e){
            $("#info").html(e);
        }
    })  
         
    return false;
}


 $(document).ready(function(){
    
    $("#right_placement").click(function(){
        var right_placement= $("#right_placement").val();
    
        if(right_placement==1)
        {  //alert('test');
        $(".div_stl001").show();
        $(".right_banner").show();
        $(".buttom_banner").hide();
        }
    });
    
    $("#buttom_placement").click(function(){
        var buttom_placement= $("#buttom_placement").val();
      
        if(buttom_placement==2)
        {
        $(".div_stl001").show();
         $(".buttom_banner").show();
        $(".right_banner").hide();
        }
    })
   
       $("#clear_logo").click(function(){
      
      var str=$("#upload").val();
    $.ajax({
       type: "POST",
       url: '<?php echo site_url('admin/banners/logo_delete'); ?>',
       data: "filename="+str,
       success: function(msg){
        
               if($("#right_placement").val()=='1'){
                 $("#info").html('<img src="<?php echo base_url()?>image/sponsorcrimepage-right.jpg" width="200" height="250">'
            + '<input type="hidden" name="upload" value="">');
            // alert( "Data Saved: " + msg );
           }
            if($("#bottom_placement").val()=='2'){
                 $("#info").html('<img src="<?php echo base_url()?>image/sponsorcrimepage-right.jpg" width="590" height="70">'
            + '<input type="hidden" name="upload" value="">');
            // alert( "Data Saved: " + msg );
           }
                
               }
           
            });
      
        });
  
    
    
    
    $("#ban_date_from").datepicker({
        dateFormat: 'yy-mm-dd',
                
    });  
     $("#ban_date_to").datepicker({
        dateFormat: 'yy-mm-dd'
         
    });  
    
   
     
   $('#ban_action').validate({
   rules:{
        ban_name:{
                    required:true
                  },
       
        ban_placement:'required',
        upload:{required:true},
        ban_impression:{required:true,digits:true},
        ban_link:{required:true,url:true},
        ban_tag:'required'
                
    },
    messages:{
         ban_name:{
            required :'Please enter title.'
         },
       
        ban_placement:'Please select placement.',
        upload:'Please upload banner image ',
        ban_impression:'Please enter  valid impression.',
        ban_link:'Please enter  valid link.',
         ban_tag:'Please enter  tag.'
        
    }
   });
  
   $('#text_detail').NobleCount('#count_detail',{
    max_chars: 500,
    block_negative: true
    });
   
    }); 
   </script>

<script type="text/javascript">

 
    String.prototype.capitalize = function(){
   return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
  };

</script>

<div id="container_wrapper">
    <div class="left_part">Banners</div>
    	<div class="right_part">
       		<div class="double_line1">
            	<h2 class="head02">Agencies directory</h2>
                </div>



<b class="purple">Banner</b>
<hr />
<b class="f13 black">Add/Edit Banner</b>
<hr />
<div class="clear"></div>

<!--<div class="clear"></div> -->

<?php
$right_display='none';
$buttom_display='none';
$placement_display = 'none';
if($ban_detail['ban_placement'] == '1')
{
$placement_display = 'block';
 $right_display = 'block';
   
}
if($ban_detail['ban_placement'] == '2')
{
$placement_display = 'block';
 $buttom_display = 'block';   
}
$placement_display = 'block';
/* ban_action form */
$attributes = array('name' => 'ban_action','id' => 'ban_action','class' => 'ban_action'); // for styling
echo form_open('banners/action',$attributes); ?>


<?php
if($ban_detail['ban_status']){
    $selected_status = $ban_detail['ban_status'];
}else if(set_value('ban_status')){
    $selected_status = set_value('ban_status');
    }

if($selected_status=='1'){
    $selected_act = "selected";
    $selected_in = '';
}elseif($selected_status=='0'){
    $selected_act = "";
    $selected_in = "selected";
}else {
    $selected_act = "true";
    $selected_in = "";
    
}
 ?>
 <div class="formstep" style="margin-bottom: 0;">
   <span class="purple"> <strong>Banner activation:</strong></span>
    <div style="height:5px; display:block;"></div>
 <div class="error_msg_label">
<div class="radios box_p">
	<div class="input_radio_form">
		<?php echo form_radio('ban_status','1',$selected_act); ?>
	</div>
	<div class="input_form002"> 
		<strong class="purple">Activate banner</strong> 
	<span> - Allow banner to be live and be viewed</span>
    </div>
	<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="radios box_p">
	<div class="input_radio_form">
		<?php echo form_radio('ban_status','0',$selected_in); ?>
	</div>
	<div class="input_form002"> 
		<strong class="purple">Deactivate banner</strong> 
        <span> - Turn banner off from public view</span>
	</div>
	<div class="clear"></div>
</div>
<div class="clear"></div>
<!--/eft ban date ends-->    

<!--/right ban date ends-->  
<!-- Banner name start-->  
<div class="formstep" style="margin-bottom: 0;">
    <strong>Banner Name: </strong> <span class="purple">*</span>
    <div style="height:5px; display:block;"></div>
 <div class="error_msg_label">
<?php 
$ban_name_input = array(
	'id'=>'ban_name',
	'name'=>'ban_name',
	'style' => 'width:580px',
    
	);
    if( $ban_detail['ban_name'])
    {$ban_name_val = $ban_detail['ban_name'];}
    else
    {$ban_name_val = set_value('ban_name');}

echo form_input($ban_name_input, $ban_name_val);
?>
</div>
<?php  echo form_error('ban_name'); ?>
<!-- Banner name end-->
<!-- Banner placement start-->
<?php
if($ban_detail['ban_placement']){
    $selected_placement = $ban_detail['ban_placement'];
}else if(set_value('ban_placement')){
    $selected_placement = set_value('ban_placement');
    }

if($selected_placement=='1'){
    $selected_act_p = "TRUE";
    $selected_in_p = '';
}elseif($selected_placement=='2'){
    $selected_act_p = "";
    $selected_in_p = "TRUE";
}
else {
    $selected_act_p = "";
    $selected_in_p = "";
    
}

$selected_act_p = "selected";
 ?>
 <div class="formstep" style="margin-bottom: 0;">
   <span class="purple"> <strong>Banner placement: </strong></span>
    <div style="height:5px; display:block;"></div>
 <div class="error_msg_label">
<div class="radios box_p">
	<div class="input_radio_form">
    <?php //echo $selected_act; ?>
    
		<?php
      /*  $right_placement_input = array(
        'class'=>'placement',
        'id'=>'right_placement',
        'name'=>'ban_placement',
        'value'=>'1',
        'checked' => $selected_act_p
        );
        echo form_radio($right_placement_input); */
         
         ?>
	</div>
	<div class="input_form002"> 
		<strong class="purple">Right Banner</strong> 
	<span> - Banner must be 120*60 nudity (includes no bare breasts or buttocks, or simulating sexual acts)</span>
    </div>
	<div class="clear"></div>
    
</div>
<div class="clear"></div>
<?php /*?><div class="radios box_p">
	<div class="input_radio_form">
		<?php
        $buttom_placement_input = array(
        'class'=>'placement',
        'id'=>'buttom_placement',
        'name'=>'ban_placement',
        'value'=>'2',
        'checked'=>$selected_in_p
                
        );
         echo form_radio($buttom_placement_input); ?>
	</div>
	<div class="input_form002"> 
		<strong class="purple">Bottom Banner</strong> 
        <span> - Banner must be 590x70px</span>
	</div>
	<div class="clear"></div>
    
</div><?php */?>
<input type="hidden" name="ban_placement" value="1"/>
<label for="ban_placement" generated="true" class="error" style="display:  none;">Please select placement.</label>
<div class="clear"></div>
<div class="div_stl001" style="display:<?php echo $placement_display; ?>">

<!-- Banner right uploader starts-->
	 <!-- <p class="gray_font"><strong>Logo</strong> <span class="purple">(optional)</span></p>-->
     <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)):?>
      <input type="file" class="file" id="fileToUpload" name="fileToUpload" onchange="return ajaxFileUpload();" /><br />
 <?php else:  ?>
    <label class="cabinet"> 
        <input type="file" class="file" id="fileToUpload" name="fileToUpload" onchange="return ajaxFileUpload();" />
    </label>
<?php endif;?>
         <!---image holder-->
         <img id="loading" src="<?php echo base_url()?>image/loading_blue.gif" style="display:none;position:absolute;z-index:1000;left: 350px; top: 450px;" />   
    <div id="info" >
       <?php if(!empty($ban_detail['ban_image']) &&  file_exists('./uploads/banners/'.$ban_detail['ban_image'])){
      
        ?>
            <img src="<?php echo base_url()?>uploads/banners/<?php echo $ban_detail['ban_image']?>" >
            <input type="hidden" name="upload" value="<?php echo $ban_detail['ban_image']?>">
           
        <?php } else{?>
        
        <div class="right_banner" style="display:<?php echo $right_display;?>">
            <img width="200" height="250" src="<?php echo base_url()?>image/sponsorcrimepage-right.jpg">  
             </div>
             
            <div class="buttom_banner" style="display:<?php echo $buttom_display;?>">  
            <img width="590" height="70" src="<?php echo base_url()?>image/sponsorcrimepage-footer.jpg">  
             </div>     
        <?php } ?>
</div>
 

       <!--image holder-->
         
         

<p class="gray_font"><strong>Upload Banner logo</strong></p>
<a href="javascript:void(0)" id="clear_logo"><span class="purple">clear current upload</span></a>

<!-- Banner right uploader end-->
</div>
<div class="clear" style="height: 5px;"></div>
<div class="radios box_p"><span class="purple">Banner:</span>(Upload GIF or JPG)</div>
<?php /*?>
<div class="clear"></div>
<!-- Banner placement end-->
  <!-- Banner name start-->  
<hr />
	<div class="radios box_p">
		<strong class="purple">Impressions</strong>
        <span> - Booked by banner views - banner will be moved to inactive once view limit is reached</span>
  </div>
<div class="clear"></div>
<!--<div class="formstep" style="margin-bottom: 0;">
    <strong>Impression limit: </strong> <span class="purple">*</span>
  -->

<?php */
$ban_impression_input = array(
	'id'=>'ban_impression',
	'name'=>'ban_impression',
	'style' => 'width:100px;margin-bottom:0',
    'value' => '1000',
    'type' => 'hidden'
    
    
	);
    if( $ban_detail['ban_impression'])
    {$ban_impression_val = $ban_detail['ban_impression'];}
    else
    {$ban_impression_val = set_value('ban_impression');}

echo form_input($ban_impression_input, $ban_impression_val,'readonly');
?>
<!--</div>
</div>
<?php /* echo form_error('ban_impression'); ?>
<hr />-->
<!-- Banner impression end-->
      <div class="clear"></div>
       <?php if($ban_detail['ban_id']!=''){ ?>
   <!-- Banner Date start-->
<span>Banner Start - <?php
if(strtotime($ban_detail['ban_date_from']) > 0){
    
       $date_start = $ban_detail['ban_date_from'];
    
           echo $date_start_format= date('d F Y \a\t H:i ',strtotime($date_start));
        
             }else{
                echo '&lt;none&gt;';
             }
  ?></span><br />
<span>Banner Finish - <?php 
if(strtotime($ban_detail['ban_date_to']) > 0 ){
       $date_start = $ban_detail['ban_date_to'];
           echo $date_start_format= date('d F Y \a\t H:i ',strtotime($date_start));
           
             }else{
                echo '&lt;currently live&gt;';
             }
  ?></span>

  <!-- Banner Date end-->  
             <div class="purple f16 "><strong>Banner Stats - <?php echo number_format($ban_detail['ban_track_view']) ; ?> Impressions - <?php echo number_format($ban_detail['ban_track_click'])  ;?> Clicks</strong></div>
             <? }else{?>
               <!-- Banner Date start-->
<span>Banner Start - &lt;none&gt;</span><br />
<span>Banner Finish - &lt;none&gt;</span>

  <!-- Banner Date end-->  
             <div class="purple f16 "><strong>Banner Stats - 0 Impressions - 0 Clicks</strong></div> 
                
            <?php }?>
   
    <hr />    <?php */?>    
   <!-- Banner link start-->   

<div class="formstep" style="margin-bottom: 0;">
    <strong>Banner link: </strong> <span class="purple">*(website link or e-mail link)</span>
    <div style="height:5px; display:block;"></div>
 <div class="error_msg_label">
     <div class="formstep" style="margin-bottom:0">
    <?php
    if($ban_detail['ban_link'])
    {$ban_link_val=$ban_detail['ban_link'];}
    else
    {$ban_link_val=set_value('ban_link');}
    
     echo form_input(array('name'=>'ban_link','id'=>'ban_link'),$ban_link_val,'style="width:580px"'); ?>
    <?php  echo form_error('ban_link'); ?>
    </div>
    </div>
    </div>
	<div class="clear"></div>
 <!-- Banner link end-->  
  <!-- Banner tag start -->   
 <div class="formstep" style="margin-bottom: 0;">
    <strong>ALT tag: </strong> <span class="purple">*</span>
    <div style="height:5px; display:block;"></div>
 <div class="error_msg_label">
     <div class="formstep" style="margin-bottom:0">
    <?php
    if($ban_detail['ban_tag'])
    {$ban_tag_val=$ban_detail['ban_tag'];}
    else
    {$ban_tag_val=set_value('ban_tag');}
    
     echo form_input(array('name'=>'ban_tag','id'=>'ban_tag'),$ban_tag_val,'style="width:580px"'); ?>
    <?php  echo form_error('ban_tag'); ?>
    </div>
    </div>
    </div>
	<div class="clear"></div>
  <!-- Banner tag end --> 

<hr />

 <div class="" style="padding-top: 5px;padding-left:200px">
     <input type="hidden" name="ban_id" value="<?php echo ($ban_detail['ban_id']!='')? $ban_detail['ban_id'] : ''; ?>" />
    	<?php echo form_submit('ban_action_submit', 'Submit'); ?> 
		<?php echo form_close(); ?>
    </div>
    


    <?php //$this->load->view(TEMPLATE_NAME.'/admin/footer_menu');?>
</div>

 </div></div> </div></div> 

</div>

        <?php $this->load->view(TEMPLATE_NAME.'/front/side_right'); ?>
         <div class="clear"></div>

<?php

$CI->load->library("front/footer_lib");
$CI->footer_lib->display_footer();
$CI->footer_lib->display_footer_element();

?>